<template>
	<view class="">
		<uni-section backgroundColor="#fff">
			<view class="uni-nav-bar" slot='navbar'>
				<image src="../../static/logos/用户.png" class="uni-user-logo" mode=""></image>
				<view style="margin-left: 10rpx;">
					<view style="display: flex;" @click="openMap">
						<text id="city" v-if="addressInfo ===null">点击定位</text>
						<text id="city" v-else>{{addressInfo.address}}</text>
						<view class="triangle">
							<map-address @setParams="getParams" ref="map"></map-address>
						</view>
					</view>
					<view class="address"><text>上街镇大学城距离您0.8公里</text></view>
				</view>
			</view>
		</uni-section>
		<scroll-view>
			<view class="select-order-type">
				<image src="../../static/logos/外送到家logo.png" @click="open1" mode="widthFix"></image>
				<image src="../../static/logos/到店自取logo.png" @click="open2" mode="widthFix"></image>
				<image src="../../static/logos/顺丰logo.png" @click="gotoOrder(3)" mode="widthFix"></image>
			</view>
			<view class="image-container">
				<view class="column">
					<view class="images">
						<image v-for="item in images1" :key="item.id" :src="item.src" mode="widthFix"></image>
					</view>
				</view>
				<view class="column">
					<view class="images">
						<image v-for="item in images2" :key="item.id" :src="item.src" mode="widthFix"></image>
					</view>
				</view>
			</view>
		</scroll-view>
		<uni-popup ref="popup2" :is-mask-click="true">
			<view class="popup-container">
				<view class="three-logos-container">
					<view class="three-logos">
						<image src="../../static/logos/threelogo.png" mode=""></image>
						<image src="../../static/logos/threelogo.png" mode=""></image>
						<image src="../../static/logos/threelogo.png" mode=""></image>
					</view>
				</view>
				<view style="width: 100%;">
					<image style="display:block;height: 28rpx; width: 280rpx;margin:56rpx auto;"
						src="../../static/logos/请选择到店の就餐方式.png"></image>
				</view>
				<view class="btn-container">
					<button @click="gotoOrder(2)">
						<image src="../../static/logos/roastchencken.png" mode=""></image>
						<view>
							<view>店内就餐</view>
							<view>Dine in</view>
						</view>
					</button>
					<button @click="gotoOrder(2)">
						<image src="../../static/logos/购物袋.png" mode=""></image>
						<view>
							<view>打包带走</view>
							<view>Take Away</view>
						</view>
					</button>
				</view>
			</view>
		</uni-popup>
		<uni-popup ref="popup1" :is-mask-click="true">
			<view class="popup-container">
				<view class="three-logos-container">
					<view class="three-logos">
						<image src="../../static/logos/threelogo.png" mode=""></image>
						<image src="../../static/logos/threelogo.png" mode=""></image>
						<image src="../../static/logos/threelogo.png" mode=""></image>
					</view>
				</view>
				<view style="width: 100%;">
					<image style="display:block;height: 84rpx; width: 560rpx;margin:24rpx auto;"
						src="../../static/logos/您的距离超出外送范围，请选择「顺丰速递」 或修改地址.png"></image>
				</view>
				<view class="btn-container">
					<button @click="gotoOrder(3)">
						<image src="../../static/logos/飞机.png" mode=""></image>
						<view>
							<view>顺丰速运</view>
						</view>
					</button>
				</view>
			</view>
		</uni-popup>
	</view>


</template>

<script>
	export default {

		data() {
			return {
				addressInfo: null,
				images1: [{
						id: 1,
						src: '../../static/logos/菜图片3.png'
					},
					{
						id: 2,
						src: '../../static/logos/菜图片2.png'
					},
					{
						id: 3,
						src: '../../static/logos/菜图片1.png'
					},
					{
						id: 4,
						src: '../../static/logos/菜图片1.png'
					},
					{
						id: 5,
						src: '../../static/logos/菜图片2.png'
					},
				],
				images2: [{
						id: 1,
						src: '../../static/logos/菜图片1.png'
					},
					{
						id: 2,
						src: '../../static/logos/菜图片2.png'
					},
					{
						id: 3,
						src: '../../static/logos/菜图片3.png'
					},
					{
						id: 4,
						src: '../../static/logos/菜图片2.png'
					},
					{
						id: 5,
						src: '../../static/logos/菜图片1.png'
					},

				],
			}
		},
		methods: {
			openMap() {
				this.$refs.map.getPlace();
			},
			getParams(params) {
				this.addressInfo = params;
				// console.log(this.addressInfo);
			},
			open2() {
				this.$refs.popup2.open('center')
			},
			open1() {
				if(this.addressInfo === null){
					this.gotoOrder(1);
				}else{
					this.$refs.popup1.open('center')
				}
			},
			close2() {
				this.$refs.popup2.close()
			},
			close1() {
				this.$refs.popup1.close()
			},
			gotoOrder(key) {
				console.log(key);
				uni.navigateTo({
					url: `/pages/Index_Menu/Index_Menu?key=${key}`
				});

			}

		}
	}
</script>

<style scoped lang='scss'>

	.uni-user-logo {
		margin-left: 26rpx;
		height: 68rpx;
		width: 68rpx;
	}

	.uni-nav-bar {
		display: flex;

		#city {
			height: 26rpx;
			margin: 8rpx 10rpx 0 10rpx;
			font-size: 26rpx;
			line-height: 100%;
			color: #000000;
		}

		.address {
			color: #AAAAAA;
			height: 24rpx;
			font-size: 24rpx;
			width: 350rpx;
			line-height: 100%;
		}
	}

	.triangle {
		margin-top: 16rpx;
		width: 0;
		height: 0;
		border-width: 10rpx;
		/*控制箭头的大小 */
		border-style: solid;
		border-color: #C4C4C4 transparent transparent transparent;
	}

	.select-order-type {
		display: flex;
		justify-content: space-between;
		padding: 34rpx;

		image {
			height: 160rpx;
			width: 206rpx;
		}
	}

	.image-container {
		padding: 0 34rpx 34rpx 34rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;

		.images {
			display: flex;
			flex-direction: column;
			flex: 1;

			image {
				width: 320rpx;
				border-radius: 60rpx;
				margin-bottom: 24rpx;
			}
		}

	}

	.popup-container {
		width: 686rpx;
		height: 312rpx;
		background: #FFFFFF;
		border-radius: 48rpx;

		.three-logos-container {
			width: 100%;

			.three-logos {
				height: 32rpx;
				width: 15%;
				margin: auto;
				display: flex;
				justify-content: space-around;

				image {
					width: 20rpx;
					height: 32rpx;
				}
			}
		}
	}

	.btn-container {
		box-sizing: border-box;
		height: 116rpx;
		width: 686rpx;
		padding: 0 32rpx;
		display: flex;
		justify-content: space-around;

		button {
			height: 100%;
			width: 278rpx;
			padding: 0;
			margin: 0;
			background-color: #fff;
			color: #BFBFBF;
			display: flex;

			&::after {
				border: none;
			}

			image {
				width: 72rpx;
				height: 72rpx;
				margin: 20rpx 20rpx 40rpx;
			}

			view {
				view:nth-child(1) {
					margin-top: 28rpx;
					height: 40rpx;
					font-size: 32rpx;
					text-align: center;
					line-height: 100%;
				}

				view:nth-child(2) {
					height: 30rpx;
					font-size: 20rpx;
					text-align: center;
					line-height: 100%;
				}
			}
		}

		button:hover {
			background: #FB7A42;
			border: 1px solid #FB7A42;
			border-radius: 24rpx;
			color: #fff;
		}
	}
</style>
